package com.example.demo.controller;

import io.swagger.annotations.Api;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;

@Controller
@Api(tags = "template测试接口")
@Slf4j
public class TemplateTestController {

    @Autowired
    private TemplateEngine templateEngine;
    @RequestMapping("/templateTest")
    public String test(Model model){
        model.addAttribute("title","title");
        model.addAttribute("heading","heading");
        model.addAttribute("content","content");
        Context context=new Context();
        context.setVariable("title","title");
        context.setVariable("heading","heading");
        context.setVariable("content","content");
        String content = templateEngine.process("sendEmail",context);
        System.out.println("content:"+content);
        return "sendEmail";
    }
}
